/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package logging.report.scribe;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import logging.report.Logger;
import logging.report.Record;
import logging.report.scribe.core.LogEntry;

/**
 *
 * @author Salm
 */
public class ScribeLogger implements Logger {

    @Override
    public void writeLog(Record record) {
        writeLogs(Arrays.asList(new Record[] {record}));
    }

    @Override
    public void writeLogs(List<Record> records) {
        List<LogEntry> entries = toLogEntries(records);
        Scribelog2.getInstance().writeLog(entries);
    }
    
    private List<LogEntry> toLogEntries(List<Record> records)
    {
        if (records.size() <= 0) return Collections.EMPTY_LIST;
        
        List<LogEntry> entries = new ArrayList(records.size());
        for (Record record : records) {
            entries.add(new LogEntry(record.getCategory(), record.toString()));
        }
        
        return entries;
    }
}
